package middleware;

import java.io.*;
import java.security.*;

public class MDConverter {
    
    public static String toMDSignature(String inp) {
	
	byte[] defaultBytes = inp.getBytes();
	try{
	    MessageDigest algorithm = MessageDigest.getInstance("MD5");
	    algorithm.reset();
	    algorithm.update(defaultBytes);
	    byte messageDigest[] = algorithm.digest();
            
	    StringBuffer hexString = new StringBuffer();
	    for (int i=0;i<messageDigest.length;i++) {
		hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
	    }
	    //String foo = messageDigest.toString();
	    return hexString.toString();
	    
	}catch(NoSuchAlgorithmException nsae){
            return "";
	}
    }
}
